package com.bkgy.controller.planking.util;

import java.math.BigDecimal;

/**
 * @author dell
 * @version 1.0
 * @description: TODO
 * @date 2025/8/27 10:43
 */
public class ProfitUtil {
    //判断厚度等级
    public static int getThickGrade(BigDecimal extThick) {
        extThick = extThick.divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_UP);
        if (extThick.compareTo(BigDecimal.valueOf(0.6)) < 0) {
            return 0;
        } else if (extThick.compareTo(BigDecimal.valueOf(0.6)) >= 0 && extThick.compareTo(BigDecimal.valueOf(0.7)) < 0) {
            return 1;
        } else if (extThick.compareTo(BigDecimal.valueOf(0.7)) >= 0 && extThick.compareTo(BigDecimal.valueOf(0.8)) < 0) {
            return 2;
        } else if (extThick.compareTo(BigDecimal.valueOf(0.8)) >= 0 && extThick.compareTo(BigDecimal.valueOf(0.9)) < 0) {
            return 3;
        } else if (extThick.compareTo(BigDecimal.valueOf(0.9)) >= 0 && extThick.compareTo(BigDecimal.valueOf(1.0)) < 0) {
            return 4;
        } else if (extThick.compareTo(BigDecimal.valueOf(1.0)) >= 0 && extThick.compareTo(BigDecimal.valueOf(1.2)) < 0) {
            return 5;
        } else if (extThick.compareTo(BigDecimal.valueOf(1.2)) >= 0 && extThick.compareTo(BigDecimal.valueOf(1.5)) < 0) {
            return 6;
        } else if (extThick.compareTo(BigDecimal.valueOf(1.5)) >= 0 && extThick.compareTo(BigDecimal.valueOf(2.1)) < 0) {
            return 7;
        } else {
            return 8;
        }
    }

    //判断宽度等级
    public static int getWidthGrade(BigDecimal extWidth) {
        extWidth = extWidth.divide(BigDecimal.TEN, 4, BigDecimal.ROUND_HALF_UP);

        if (extWidth.compareTo(BigDecimal.valueOf(1200)) < 0) {
            return 0;
        } else if (extWidth.compareTo(BigDecimal.valueOf(1200)) >= 0 && extWidth.compareTo(BigDecimal.valueOf(1300)) < 0) {
            return 1;
        } else if (extWidth.compareTo(BigDecimal.valueOf(1300)) >= 0 && extWidth.compareTo(BigDecimal.valueOf(1500)) < 0) {
            return 2;
        } else if (extWidth.compareTo(BigDecimal.valueOf(1500)) >= 0 && extWidth.compareTo(BigDecimal.valueOf(1600)) < 0) {
            return 3;
        } else {
            return 4;
        }
    }
}
